package com.aspose.cells;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

public class Workbook {
   private WorkbookSettings j;
   private WorksheetCollection k;
   boolean a = false;
   private String l = "";
   private DataSorter m;
   zps b = null;
   private int n = 3;
   private int o = 128;
   private SaveOptions p;
   zqm c = new zqm();
   boolean d = false;
   int e = 6;
   private int q = 1;
   private InterruptMonitor r;
   ContentTypePropertyCollection f;
   zng g;
   private String s;
   ExternalConnectionCollection h;
   private DigitalSignatureCollection t;
   zrj i;
   private HashMap u = new HashMap();
   private static final com.aspose.cells.b.c.a.za v = new com.aspose.cells.b.c.a.za(new String[]{"\u0005SummaryInformation", "\u0005DocumentSummaryInformation"});

   String a(String var1) {
      String var2 = (String)this.getSettings().h().get(var1);
      return var2 == null ? var1 : var2;
   }

   public WorkbookSettings getSettings() {
      return this.j;
   }

   public void setSettings(WorkbookSettings value) {
      this.j = value;
   }

   public Workbook() {
      this.d(6);
      this.j = new WorkbookSettings(this, 0);
      this.k = new WorksheetCollection(this);
      this.k.s();
   }

   public Workbook(int fileFormatType) {
      this.d(fileFormatType);
      this.j = new WorkbookSettings(this, 0);
      this.k = new WorksheetCollection(this);
      this.k.s();
   }

   public Workbook(String file) throws Exception {
      this.a(file, new LoadOptions());
   }

   public Workbook(InputStream stream) throws Exception {
      com.aspose.cells.b.a.d.zh var2 = new com.aspose.cells.b.a.d.zh(stream);
      this.a(var2, new LoadOptions(), true);
   }

   public Workbook(String file, LoadOptions loadOptions) throws Exception {
      this.a(file, loadOptions);
   }

   public Workbook(InputStream stream, LoadOptions loadOptions) throws Exception {
      com.aspose.cells.b.a.d.zh var3 = new com.aspose.cells.b.a.d.zh(stream);
      this.a(var3, loadOptions, true);
   }

   Workbook(com.aspose.cells.b.a.d.zm stream, LoadOptions loadOptions) throws Exception {
      this.a(stream, loadOptions, true);
   }

   public void initialize() {
      this.l = "";
      this.k.clear();
      this.k = null;
      this.j = new WorkbookSettings(this, 0);
      this.k = new WorksheetCollection(this);
      this.k.s();
      this.b = null;
      this.n = 0;
      this.o = 128;
      this.c();
      this.p = null;
   }

   void a() {
   }

   private void b(int var1, boolean var2) {
      if (var2) {
         this.d(var1);
         this.j.a(var1, this.q, true);
      } else {
         this.p = null;
         this.l = "";
         this.k = new WorksheetCollection(this);
         this.k.s();
         this.d(var1);
         this.j.a(var1, this.q, false);
         this.b = null;
         this.c = new zqm();
         this.d = false;
         this.c();
      }

   }

   void b() {
      this.d();
      this.c();
   }

   void c() {
      if (this.a) {
         this.a = false;

         Worksheet var2;
         for(Iterator var1 = this.k.iterator(); var1.hasNext(); var2.getCells().b.e = null) {
            var2 = (Worksheet)var1.next();
         }
      }

   }

   void d() {
      if (!this.getSettings().getParsingFormulaOnOpen() && !this.getSettings().m && this.i() == 1) {
         for(int var5 = this.k.getCount() - 1; var5 > -1; --var5) {
            Cells var1 = this.k.get(var5).getCells();
            zaau var3 = var1.b;
            if (var3.c >= 1) {
               zafu var2 = var1.getRows().a;

               for(int var6 = var3.b.length - 1; var6 > -1; --var6) {
                  zyi var7 = var3.b[var6];
                  if (var7 != null && var7.j()) {
                     Cell var4 = var2.a(var7.e, var7.f);
                     if (var4 != null && var4.c.d == var7) {
                        var7.a(this.getWorksheets(), var5);
                     } else {
                        var3.b(var6);
                     }
                  }
               }
            }
         }

         this.getSettings().m = true;
      }
   }

   private void a(String var1, LoadOptions var2) throws Exception {
      this.j = new WorkbookSettings(this, var2.getRegion());
      this.j.a = var2;
      this.k = new WorksheetCollection(this);
      this.k.s();
      this.getSettings().setPassword(var2.getPassword());
      this.getSettings().setParsingFormulaOnOpen(var2.getParsingFormulaOnOpen());
      this.getSettings().setLanguageCode(var2.getLanguageCode());
      if (var2.b) {
         this.getSettings().a(var2.getStandardFont());
      }

      if (var2.c) {
         this.getSettings().a(var2.getStandardFontSize());
      }

      this.j.n = var2.getIgnoreNotPrinted();
      this.j.o = var2.a();
      this.j.setMemorySetting(var2.getMemorySetting());
      this.j.setCheckExcelRestriction(var2.getCheckExcelRestriction());
      this.r = var2.getInterruptMonitor();
      com.aspose.cells.b.a.d.ze var3 = null;

      label216: {
         try {
            var3 = com.aspose.cells.b.a.d.zd.a(var1, 3, 1, 3);
            if (var3.h() == 0L) {
               return;
            }

            if (var2.getLoadFormat() != 0) {
               this.a(var3, var2, false);
               break label216;
            }

            boolean var4 = false;
            byte var5 = 0;
            boolean[] var6 = new boolean[]{var4};
            int[] var7 = new int[]{var5};
            var2.a(zakq.a(var1, var3, var6, var7));
            var4 = var6[0];
            int var18 = var7[0];
            if (!var4) {
               switch(var18) {
               case 9:
                  throw new CellsException(19, "This Excel file contains (Excel2.1 or earlier file format) records.");
               case 521:
                  throw new CellsException(19, "This Excel file contains (Excel3.0 or earlier file format) records.");
               case 1033:
                  throw new CellsException(19, "This Excel file contains (Excel4.0 or earlier file format) records.");
               case 2057:
                  throw new CellsException(19, "This Excel file contains (Excel95 or earlier file format) records.");
               default:
                  throw new CellsException(4, "This file's format is not supported or you don't specify a correct format.");
               }
            }

            if (var2.getLoadFormat() == 13) {
               zbps var20 = new zbps();
               zamn var23 = new zamn(var20);
               var23.a(var1, this, var2);
               return;
            }

            if (var2.getLoadFormat() != 12) {
               if (var2.getLoadFormat() == 5) {
                  zvh var19 = new zvh(var3);
                  if (var19.a().a("EncryptionInfo") != null) {
                     com.aspose.cells.b.a.d.zm var9 = this.b(var19);
                     byte var10 = 6;
                     this.a(var9);
                     zps var11 = this.b;
                     com.aspose.cells.a.f.zi var12 = var11.b.b;
                     String var13 = "xl/workbook.bin";
                     if (var12.a(var13, true) != -1) {
                        var10 = 16;
                     }

                     switch(var10) {
                     case 16:
                        this.b(16, true);
                        this.b = var11;
                        zcda var14 = new zcda(this);
                        var14.a();
                        break label216;
                     default:
                        this.b(6, true);
                        if (var2.getLoadDataAndFormatting()) {
                           zajv.a(this, var12, var2.getLoadDataOptions());
                        } else {
                           this.b = var11;
                           zajt.a(this, var2);
                        }
                     }
                  } else {
                     if (zbwo.a(var19) == null) {
                        if (var19.a().a("WordDocument") != null) {
                           throw new CellsException(4, "This is a word doc file.");
                        }

                        if (var19.a().a("PowerPoint Document") != null) {
                           throw new CellsException(4, "This is a PowerPoint file.");
                        }

                        throw new CellsException(4, "This file's format is not supported or you don't specify a correct format.");
                     }

                     this.b(5, true);
                     if (var2.getLoadDataAndFormatting()) {
                        zpy var21 = new zpy(this, var2.getLoadDataOptions());
                        var21.a(var19);
                     } else if (var2.getOnlyLoadDocumentProperties()) {
                        this.a(var19);
                        this.getWorksheets().a(var19);
                     } else {
                        zbwo var22 = new zbwo(this, var2);
                        var22.c(var19);
                        this.getWorksheets().a(var19);
                     }
                  }
               } else {
                  this.a(var3, var2, false);
               }
               break label216;
            }

            zafd var8 = new zafd();
            var8.a(var1, this, var2);
         } finally {
            if (var3 != null) {
               var3.a();
            }

         }

         return;
      }

      this.b(var1);
   }

   private void a(com.aspose.cells.b.a.d.zm var1, LoadOptions var2, boolean var3) throws Exception {
      if (var3) {
         this.j = new WorkbookSettings(this, var2.getRegion());
         this.k = new WorksheetCollection(this);
         this.k.s();
      }

      this.j.a = var2;
      this.getSettings().setPassword(var2.getPassword());
      this.getSettings().setParsingFormulaOnOpen(var2.getParsingFormulaOnOpen());
      this.getSettings().setLanguageCode(var2.getLanguageCode());
      this.getSettings().setRegion(var2.getRegion());
      this.getSettings().setMemorySetting(var2.getMemorySetting());
      if (var2.b) {
         this.getSettings().a(var2.getStandardFont());
      }

      if (var2.c) {
         this.getSettings().a(var2.getStandardFontSize());
      }

      this.j.n = var2.getIgnoreNotPrinted();
      this.j.o = var2.a();
      this.j.setCheckExcelRestriction(var2.getCheckExcelRestriction());
      this.r = var2.getInterruptMonitor();
      if (((com.aspose.cells.b.a.d.zm)var1).h() != 0L) {
         com.aspose.cells.a.c.zl.c("Initialization of workbook finished.");
         if (var2.getLoadFormat() == 0) {
            boolean var4 = false;
            int var6;
            if (!((com.aspose.cells.b.a.d.zm)var1).e()) {
               byte[] var5 = new byte[(int)((com.aspose.cells.b.a.d.zm)var1).h()];
               var6 = 0;

               for(int var7 = 0; var7 > 0; var6 += var7) {
                  var7 = ((com.aspose.cells.b.a.d.zm)var1).a(var5, var6, var5.length - var6);
               }

               var1 = new com.aspose.cells.b.a.d.zh(var5);
               var4 = true;
            }

            ((com.aspose.cells.b.a.d.zm)var1).a(0L, 0);
            boolean var17 = false;
            byte var20 = 0;
            boolean[] var22 = new boolean[]{var17};
            int[] var8 = new int[]{var20};
            var2.a(zakq.a((String)null, (com.aspose.cells.b.a.d.zm)var1, var22, var8));
            var17 = var22[0];
            var6 = var8[0];
            if (!var17) {
               switch(var6) {
               case 9:
                  throw new CellsException(19, "This Excel file contains (Excel2.1 or earlier file format) records.");
               case 521:
                  throw new CellsException(19, "This Excel file contains (Excel3.0 or earlier file format) records.");
               case 1033:
                  throw new CellsException(19, "This Excel file contains (Excel4.0 or earlier file format) records.");
               case 2057:
                  throw new CellsException(19, "This Excel file contains (Excel95 or earlier file format) records.");
               default:
                  throw new CellsException(4, "This file's format is not supported or you don't specify a correct format.");
               }
            }

            if (var2.getLoadFormat() == 6) {
               if (!var4) {
                  com.aspose.cells.b.a.d.zh var9 = new com.aspose.cells.b.a.d.zh();
                  zakq.a((com.aspose.cells.b.a.d.zm)var1, (com.aspose.cells.b.a.d.zm)var9);
                  var9.b(0L);
                  var1 = var9;
               }

               this.a((com.aspose.cells.b.a.d.zm)var1);
               zps var31 = this.b;
               com.aspose.cells.a.f.zi var10 = var31.b.b;
               if (var10.a("xl/workbook.xml", true) != -1) {
                  this.b(6, true);
                  if (var2.getLoadDataAndFormatting()) {
                     zajv.a(this, var10, var2.getLoadDataOptions());
                  } else {
                     this.b = var31;
                     zajt.a(this, var2);
                  }

                  return;
               }

               if (var10.a("xl/workbook.bin", true) != -1) {
                  this.b(16, true);
                  this.b = var31;
                  zcda var39 = new zcda(this);
                  var39.a();
                  return;
               }

               if (var10.a("content.xml", true) != -1) {
                  this.b(14, true);
                  zari var11 = new zari(this);
                  var11.a(var10);
                  return;
               }
            } else if (var2.getLoadFormat() == 5) {
               zvh var34 = new zvh((com.aspose.cells.b.a.d.zm)var1);
               if (var34.a().a("EncryptionInfo") != null) {
                  com.aspose.cells.b.a.d.zm var36 = this.b(var34);
                  byte var40 = 6;
                  this.a(var36);
                  zps var12 = this.b;
                  com.aspose.cells.a.f.zi var13 = var12.b.b;
                  String var14 = "xl/workbook.bin";
                  if (var13.a(var14, true) != -1) {
                     var40 = 16;
                  }

                  switch(var40) {
                  case 16:
                     this.b(16, true);
                     this.b = var12;
                     zcda var15 = new zcda(this);
                     var15.a();
                     break;
                  default:
                     this.b(6, true);
                     if (var2.getLoadDataAndFormatting()) {
                        zajv.a(this, var13, var2.getLoadDataOptions());
                     } else {
                        this.b = var12;
                        zajt.a(this, var2);
                     }
                  }
               } else {
                  if (zbwo.a(var34) == null) {
                     if (var34.a().a("WordDocument") != null) {
                        throw new CellsException(4, "This is a word doc file.");
                     }

                     if (var34.a().a("PowerPoint Document") != null) {
                        throw new CellsException(4, "This is a PowerPoint file.");
                     }

                     throw new CellsException(4, "This file's format is not supported or you don't specify a correct format.");
                  }

                  this.b(5, true);
                  if (var2.getLoadDataAndFormatting()) {
                     zpy var37 = new zpy(this, var2.getLoadDataOptions());
                     var37.a(var34);
                  } else if (var2.getOnlyLoadDocumentProperties()) {
                     this.a(var34);
                     this.getWorksheets().a(var34);
                  } else {
                     zbwo var38 = new zbwo(this, var2);
                     var38.c(var34);
                     this.getWorksheets().a(var34);
                  }
               }

               return;
            }
         }

         com.aspose.cells.b.a.d.zn var16;
         if (var2 instanceof TxtLoadOptions) {
            TxtLoadOptions var19 = (TxtLoadOptions)var2;
            this.b(1, true);
            if (!var19.d) {
               this.getSettings().a(var19.getEncoding());
            }

            var16 = new com.aspose.cells.b.a.d.zn((com.aspose.cells.b.a.d.zm)var1, this.getSettings().f());
            zbvi.a((com.aspose.cells.b.a.d.zn)var16, this.k.get(0).getCells(), 0, 0, var19);
         } else {
            com.aspose.cells.b.a.d.za var21;
            long var25;
            TxtLoadOptions var28;
            switch(var2.getLoadFormat()) {
            case 1:
               this.b(1, true);
               var28 = new TxtLoadOptions();
               var28.setConvertNumericData(var2.getConvertNumericData());
               if (this.getSettings().i) {
                  var16 = new com.aspose.cells.b.a.d.zn((com.aspose.cells.b.a.d.zm)var1);
               } else {
                  var16 = new com.aspose.cells.b.a.d.zn((com.aspose.cells.b.a.d.zm)var1, this.getSettings().f());
                  var28.setEncoding(this.getSettings().f());
               }

               zbvi.a((com.aspose.cells.b.a.d.zn)var16, this.k.get(0).getCells(), 0, 0, var28);
               break;
            case 2:
            case 3:
            case 4:
            case 7:
            case 8:
            case 9:
            case 10:
            default:
               throw new CellsException(4, "This file's format is not supported or you don't specify a correct format.");
            case 5:
               this.b(5, true);
               zvh var30;
               if (var2.getLoadDataAndFormatting()) {
                  var30 = new zvh((com.aspose.cells.b.a.d.zm)var1);
                  zpy var29 = new zpy(this, var2.getLoadDataOptions());
                  var29.a(var30);
               } else if (var2.getOnlyLoadDocumentProperties()) {
                  var30 = new zvh((com.aspose.cells.b.a.d.zm)var1);
                  this.a(var30);
                  this.getWorksheets().a(var30);
               } else {
                  zbwo var35 = new zbwo(this, var2);
                  zvh var32 = var35.a((com.aspose.cells.b.a.d.zm)var1);
                  this.getWorksheets().a(var32);
               }
               break;
            case 6:
               this.b(6, true);
               var21 = new com.aspose.cells.b.a.d.za((com.aspose.cells.b.a.d.zm)var1);
               var25 = var21.s();
               ((com.aspose.cells.b.a.d.zm)var1).a(0L, 0);
               if (var25 == -2226271756974174256L) {
                  var1 = this.b(new zvh((com.aspose.cells.b.a.d.zm)var1));
               }

               if (var2.getLoadDataAndFormatting()) {
                  zajv.a(this, (com.aspose.cells.b.a.d.zm)var1, var2.getLoadDataOptions());
               } else {
                  this.a((com.aspose.cells.b.a.d.zm)var1);
                  zajt.a(this, var2);
               }
               break;
            case 11:
               this.b(11, true);
               var28 = new TxtLoadOptions();
               var28.setConvertNumericData(var2.getConvertNumericData());
               if (this.getSettings().i) {
                  var16 = new com.aspose.cells.b.a.d.zn((com.aspose.cells.b.a.d.zm)var1);
               } else {
                  var16 = new com.aspose.cells.b.a.d.zn((com.aspose.cells.b.a.d.zm)var1, this.getSettings().f());
                  var28.setEncoding(this.getSettings().f());
               }

               var28.setSeparator('\t');
               zbvi.a((com.aspose.cells.b.a.d.zn)var16, this.k.get(0).getCells(), 0, 0, var28);
               break;
            case 12:
               zafd var26 = new zafd();
               var26.a((com.aspose.cells.b.a.d.zm)var1, this, var2);
               break;
            case 13:
               zbps var24 = new zbps();
               zamn var27 = new zamn(var24);
               var27.a((com.aspose.cells.b.a.d.zm)var1, this, var2);
               break;
            case 14:
               this.b(14, true);
               zari var18 = new zari(this);
               var18.a((com.aspose.cells.b.a.d.zm)var1);
               break;
            case 15:
               this.b(15, true);
               zbbt var23 = new zbbt();
               var23.a((com.aspose.cells.b.a.d.zm)var1, (Workbook)this);
               break;
            case 16:
               this.b(16, true);
               var21 = new com.aspose.cells.b.a.d.za((com.aspose.cells.b.a.d.zm)var1);
               var25 = var21.s();
               ((com.aspose.cells.b.a.d.zm)var1).a(0L, 0);
               if (var25 == -2226271756974174256L) {
                  var1 = this.b(new zvh((com.aspose.cells.b.a.d.zm)var1));
               }

               this.a((com.aspose.cells.b.a.d.zm)var1);
               zcda var33 = new zcda(this);
               var33.a();
            }

         }
      }
   }

   private void a(zvh var1) throws Exception {
      ArrayList var2 = new ArrayList();
      Iterator var3 = var1.a().c().iterator();

      while(var3.hasNext()) {
         String var4 = (String)var3.next();
         switch(v.a(var4)) {
         case 0:
         case 1:
            break;
         default:
            com.aspose.cells.b.a.a.ze.a(var2, (Object)var4);
         }
      }

      for(int var5 = 0; var5 < var2.size(); ++var5) {
         var1.a().g(var2.get(var5));
      }

      zbwo.a(var1, this.getWorksheets());
   }

   public void save(String fileName) throws Exception {
      String var2 = com.aspose.cells.b.a.d.zk.d(fileName);
      int var3 = FileFormatUtil.a(var2, this.e);
      this.save(fileName, FileFormatUtil.a(var3, this.getSaveOptions()));
   }

   public void save(String fileName, int saveFormat) throws Exception {
      SaveOptions var3 = FileFormatUtil.a(fileName, saveFormat, this.p);
      this.save(fileName, var3);
   }

   public void save(String fileName, SaveOptions saveOptions) throws Exception {
      String var3;
      if (saveOptions.getCreateDirectory()) {
         var3 = com.aspose.cells.b.a.d.zk.e(fileName);
         if (!com.aspose.cells.b.a.d.zc.a(var3)) {
            com.aspose.cells.b.a.d.zc.b(var3);
         }
      }

      if (saveOptions instanceof HtmlSaveOptions) {
         this.p = saveOptions;
         var3 = null;
         HtmlSaveOptions var4 = (HtmlSaveOptions)saveOptions;
         if (var4.getExportActiveWorksheetOnly()) {
            var3 = this.getWorksheets().get(this.getWorksheets().getActiveSheetIndex()).getName();
         }

         zaec var5 = new zaec(this, fileName, var3, var4);
         var5.a();
      } else {
         if (saveOptions instanceof OoxmlSaveOptions) {
            switch(saveOptions.getSaveFormat()) {
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
               break;
            default:
               int var11 = FileFormatUtil.extensionToSaveFormat(com.aspose.cells.b.a.d.zk.d(fileName));
               switch(var11) {
               case 6:
               case 7:
               case 8:
               case 9:
               case 10:
                  saveOptions.a(var11);
               }
            }
         } else if (saveOptions instanceof XlsSaveOptions && ".xlt".equals(com.aspose.cells.b.a.d.zk.d(fileName))) {
            ((XlsSaveOptions)saveOptions).a = true;
         }

         com.aspose.cells.b.a.d.ze var12 = com.aspose.cells.b.a.d.zd.a(fileName);

         try {
            this.a((com.aspose.cells.b.a.d.zm)var12, (SaveOptions)saveOptions);
         } catch (Exception var9) {
            throw var9;
         } finally {
            if (var12 != null) {
               var12.a();
            }

         }

         if (this.l == null || "".equals(this.l)) {
            this.l = fileName;
         }

      }
   }

   public void save(OutputStream stream, int saveFormat) throws Exception {
      this.save(stream, FileFormatUtil.a((String)null, saveFormat, this.p));
   }

   public void save(OutputStream stream, SaveOptions saveOptions) throws Exception {
      String var3 = saveOptions.getCachedFileFolder();
      if (var3 != null && var3.length() > 0) {
         com.aspose.cells.b.a.d.ze var7;
         byte[] var8;
         switch(var3.charAt(var3.length() - 1)) {
         default:
            var3 = var3 + '/';
         case '/':
         case '\\':
            var3 = var3 + "Aspose.Cells" + com.aspose.cells.b.a.zr.a(com.aspose.cells.b.a.zh.b());
            var3 = var3 + ".xls";
            var7 = com.aspose.cells.b.a.d.zd.a(var3);
            this.a((com.aspose.cells.b.a.d.zm)var7, (SaveOptions)saveOptions);
            var7.b(0L);
            var8 = new byte[4096];
         }

         while(true) {
            int var6 = var7.a((byte[])var8, 0, var8.length);
            if (var6 <= 0) {
               var7.a();
               com.aspose.cells.b.a.d.zd.d(var3);
               break;
            }

            stream.write(var8, 0, var6);
         }
      } else {
         boolean var4 = true;
         switch(saveOptions.getSaveFormat()) {
         case 6:
         case 7:
         case 8:
         case 9:
            if ((this.getSettings().getPassword() == null || "".equals(this.getSettings().getPassword())) && (this.getWorksheets().i == null || (this.getWorksheets().i.b() & '\uffff') == 0)) {
               var4 = false;
               this.a((com.aspose.cells.b.a.d.zm)(new com.aspose.cells.b.a.d.zj(stream)), (SaveOptions)saveOptions);
            }
         }

         if (var4) {
            com.aspose.cells.b.a.d.zh var5 = new com.aspose.cells.b.a.d.zh();
            this.a((com.aspose.cells.b.a.d.zm)var5, (SaveOptions)saveOptions);
            var5.a(0L, 0);
            var5.a(stream);
         }
      }

   }

   void a(com.aspose.cells.b.a.d.zm var1, SaveOptions var2) throws Exception {
      this.p = var2;
      int var3;
      Worksheet var4;
      if (var2.getRefreshChartCache()) {
         for(var3 = 0; var3 < this.getWorksheets().getCount(); ++var3) {
            var4 = this.getWorksheets().get(var3);

            for(int var5 = 0; var5 < var4.getCharts().getCount(); ++var5) {
               var4.getCharts().get(var5).g();
            }
         }
      }

      for(var3 = 0; var3 < this.k.getCount(); ++var3) {
         var4 = this.k.get(var3);
         var4.d(var3);
      }

      var3 = FileFormatUtil.a(var2.getSaveFormat(), this.e);
      if (var2 instanceof SpreadsheetML2003SaveOptions) {
         this.a(var3, ((SpreadsheetML2003SaveOptions)var2).getLimitAsXls());
      } else {
         this.setFileFormat(var3);
      }

      zcel var8;
      WorkbookRender var17;
      HtmlSaveOptions var22;
      com.aspose.cells.b.a.d.zh var24;
      switch(var2.getSaveFormat()) {
      case 1:
      case 11:
         TxtSaveOptions var21 = TxtSaveOptions.a(this.getSettings(), var2.getSaveFormat(), var2);
         zsy.a(var1, this, var21);
         return;
      case 2:
      case 3:
      case 4:
      case 5:
      case 18:
      case 19:
      case 23:
      case 24:
      case 25:
      case 26:
      case 27:
      case 28:
      case 29:
      default:
         if (var1.e()) {
            (new zbwp(this, var2)).a(var1);
         } else {
            com.aspose.cells.b.a.d.zh var18 = new com.aspose.cells.b.a.d.zh();
            (new zbwp(this, var2)).a((com.aspose.cells.b.a.d.zm)var18);
            var18.a(var1);
         }

         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 6:
      case 7:
      case 8:
      case 9:
      case 10:
         if ((this.getSettings().getPassword() == null || "".equals(this.getSettings().getPassword())) && this.getSettings().isDefaultEncrypted() && this.getSettings().isProtected() && (this.getWorksheets().i.b() & '\uffff') != 0) {
            this.getSettings().setPassword("VelvetSweatshop");
         }

         if (this.getSettings().getPassword() != null && !"".equals(this.getSettings().getPassword())) {
            var24 = new com.aspose.cells.b.a.d.zh();
            zuc.a(this, var24, var3, var2);
            var24.a(0L, 0);
            zbv var28 = new zbv(this.getSettings().getPassword(), this.o);
            com.aspose.cells.b.a.d.zh var29 = var28.b();
            var24 = var28.b(var24);
            zvh var30 = new zvh(WorksheetCollection.h);
            var30.a().a("EncryptionInfo", var29);
            var30.a().a("EncryptedPackage", var24);
            var30.a(var1);
         } else {
            zuc.a(this, var1, var3, var2);
         }

         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 12:
         var22 = (HtmlSaveOptions)var2;
         String var25 = null;
         if (var22.getExportActiveWorksheetOnly()) {
            var25 = this.getWorksheets().get(this.getWorksheets().getActiveSheetIndex()).getName();
         }

         zaec var27 = new zaec(this, var1, var25, var22);
         var27.a();
         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 13:
         zbuz var20 = new zbuz(this);
         var20.a(var1);
         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 14:
         this.d();
         zarj var19 = new zarj(this);
         var19.a(var1);
         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 15:
         zbbr.a(this, var1, var2);
         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 16:
         if ((this.getSettings().getPassword() == null || "".equals(this.getSettings().getPassword())) && this.getSettings().isProtected() && (this.getWorksheets().N().b() & '\uffff') != 0) {
            this.getSettings().setPassword("VelvetSweatshop");
         }

         if (this.getSettings().getPassword() != null && !"".equals(this.getSettings().getPassword())) {
            var24 = new com.aspose.cells.b.a.d.zh();
            var8 = new zcel(this, this.hasMacro());
            var8.a((com.aspose.cells.b.a.d.zm)var24);
            var24.a(0L, 0);
            zbv var26 = new zbv(this.getSettings().getPassword(), this.o);
            com.aspose.cells.b.a.d.zh var10 = var26.b();
            var24 = var26.b(var24);
            zvh var11 = new zvh(WorksheetCollection.h);
            var11.a().a("EncryptionInfo", var10);
            var11.a().a("EncryptedPackage", var24);
            var11.a(var1);
         } else {
            zcel var23 = new zcel(this, this.hasMacro());
            var23.a(var1);
         }

         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 17:
         var22 = (HtmlSaveOptions)var2;
         var8 = null;
         if (var22.getExportActiveWorksheetOnly()) {
            this.getWorksheets().get(this.getWorksheets().getActiveSheetIndex()).getName();
         }

         zanm var9 = new zanm(this, var1, var22);
         var9.a(var1);
         if (this.getSaveOptions().getClearData()) {
            this.initialize();
         } else {
            this.a();
         }

         return;
      case 20:
         XpsSaveOptions var15 = XpsSaveOptions.a(var2);
         var17 = new WorkbookRender(this, var15.b());
         var17.a(var1);
         return;
      case 21:
         ImageSaveOptions var14 = ImageSaveOptions.a(var2);
         var17 = new WorkbookRender(this, var14.getImageOrPrintOptions());
         var17.a(var1);
         return;
      case 22:
         SvgSaveOptions var13 = SvgSaveOptions.c(var2);
         Worksheet var16 = this.getWorksheets().get(var13.getSheetIndex() == -1 ? this.getWorksheets().getActiveSheetIndex() : var13.getSheetIndex());
         SheetRender var6 = new SheetRender(var16, var13.getImageOrPrintOptions());

         for(int var7 = 0; var7 < var6.getPageCount(); ++var7) {
            var6.a(var7, var1);
         }

         return;
      case 30:
         zrb var12 = new zrb(this);
         var12.a(var1);
      }
   }

   public WorksheetCollection getWorksheets() {
      return this.k;
   }

   public boolean isLicensed() {
      zhk var1 = new zhk();
      return var1.a();
   }

   /** @deprecated */
   public StyleCollection getStyles() {
      return this.k.r();
   }

   public Style createStyle() {
      Style var1 = new Style(this.k);
      var1.a((WorksheetCollection)this.k, (int)15);
      return var1;
   }

   public CellsColor createCellsColor() {
      return new CellsColor(this);
   }

   public int replace(String placeHolder, String newValue) {
      zve var3 = new zve(this.k);
      return var3.a(placeHolder, newValue);
   }

   public int replace(String placeHolder, int newValue) {
      zve var3 = new zve(this.k);
      return var3.a(placeHolder, newValue);
   }

   public int replace(String placeHolder, double newValue) {
      zve var4 = new zve(this.k);
      return var4.a(placeHolder, newValue);
   }

   public int replace(String placeHolder, String[] newValues, boolean isVertical) {
      zve var4 = new zve(this.k);
      return var4.a(placeHolder, newValues, isVertical);
   }

   public int replace(String placeHolder, int[] newValues, boolean isVertical) {
      zve var4 = new zve(this.k);
      return var4.a(placeHolder, newValues, isVertical);
   }

   public int replace(String placeHolder, double[] newValues, boolean isVertical) {
      zve var4 = new zve(this.k);
      return var4.a(placeHolder, newValues, isVertical);
   }

   public int replace(boolean boolValue, Object newValue) {
      zve var3 = new zve(this.k);
      return var3.a(boolValue, newValue);
   }

   public int replace(int intValue, Object newValue) {
      zve var3 = new zve(this.k);
      return var3.a(intValue, newValue);
   }

   public int replace(String placeHolder, String newValue, ReplaceOptions options) {
      zve var4 = new zve(this.k, options);
      return var4.a(placeHolder, newValue);
   }

   public void copy(Workbook source) throws Exception {
      this.k.t();
      this.e = source.e;
      this.q = source.q;
      this.k.a(source.k);
      this.c.a(source.c);
      this.d = source.d;
      this.j.a(source.j);
      this.b = source.b;
      this.getDataConnections().a(source.getDataConnections());
      this.s = source.s;
      if (source.g != null) {
         this.m().a(source.g);
      }

      if (source.f != null) {
         this.getContentTypeProperties().a(source.f);
      }

   }

   public void combine(Workbook secondWorkbook) throws Exception {
      this.d();
      secondWorkbook.d();
      this.k.b(secondWorkbook.k);
   }

   public Color[] getColors() {
      return this.j.c().c();
   }

   public Style getStyleInPool(int index) {
      return this.getWorksheets().B().a(index);
   }

   public int getCountOfStylesInPool() {
      return this.getWorksheets().B().getCount();
   }

   public Style getNamedStyle(String name) {
      return this.getWorksheets().B().a(name);
   }

   public void changePalette(Color color, int index) {
      if (index >= 0 && index <= 55) {
         this.j.c().a(color, index + 8);
      } else {
         throw new IllegalArgumentException("Index is out of range.");
      }
   }

   public boolean isColorInPalette(Color color) {
      return this.j.c().b(color);
   }

   public void calculateFormula() {
      this.calculateFormula(false, (ICustomFunction)null);
   }

   public void calculateFormula(boolean ignoreError) {
      this.calculateFormula(ignoreError, (ICustomFunction)null);
   }

   public void calculateFormula(boolean ignoreError, ICustomFunction customFunction) {
      if (!CalculationOptions.a) {
         CalculationOptions var29 = new CalculationOptions();
         var29.b = ignoreError;
         var29.setCustomFunction(customFunction);
         this.calculateFormula(var29);
      } else {
         boolean var3 = !this.getSettings().getParsingFormulaOnOpen() && !this.getSettings().m && this.i() == 1;
         boolean var4 = true;
         boolean var5 = false;
         int var6 = this.k.getCount();

         int var7;
         for(var7 = 0; var7 < var6; ++var7) {
            zaau var8 = this.k.get(var7).getCells().b;
            if (this.j.getCreateCalcChain() && var8.e == null) {
               var8.e = new zyq(var8);
            }

            if (var8.c > 0) {
               zyi[] var9 = var8.b;
               if (var4) {
                  var4 = false;
               }

               int var10;
               if (var3) {
                  for(var10 = var9.length - 1; var10 > -1; --var10) {
                     if (var9[var10] != null && var9[var10].j()) {
                        var3 = false;
                        var5 = true;
                        break;
                     }
                  }
               }

               if (!this.a) {
                  for(var10 = 0; var10 < var9.length; ++var10) {
                     if (var9[var10] != null) {
                        var9[var10].a((byte)0);
                     }
                  }
               }
            }
         }

         if (!var4) {
            boolean var24 = false;

            try {
               var24 = true;

               Cells var30;
               for(int var31 = 0; var31 < var6; ++var31) {
                  var30 = this.k.get(var31).getCells();
                  var30.getRows().a(16);
               }

               if (var5) {
                  this.d();
               }

               zyh var32 = new zyh(this);
               var32.a(0);
               var32.a(ignoreError, customFunction);
               Cell var11;
               zyi var12;
               zafu var33;
               zaau var34;
               if (!this.a) {
                  int var35 = 0;

                  while(true) {
                     if (var35 >= var6) {
                        if (this.j.getCreateCalcChain()) {
                           this.a = true;
                           var24 = false;
                        } else {
                           var24 = false;
                        }
                        break;
                     }

                     var30 = this.k.get(var35).getCells();
                     var34 = var30.b;
                     if (var34.c >= 1) {
                        var33 = var30.getRows().a;

                        for(int var36 = 0; var36 < var34.b.length; ++var36) {
                           var12 = var34.a(var36);
                           if (var12 != null && var12.c() != 2) {
                              var11 = var33.a(var12.e, var12.f);
                              if (var11 != null && var11.c.d == var12) {
                                 try {
                                    var32.a(var11);
                                 } catch (zhs var25) {
                                    var32.a();
                                 } catch (Exception var26) {
                                    if (!ignoreError) {
                                       throw new CellsException(5, "Error in calculating cell [" + var11.d.h().getName() + "!" + var11.i() + "]: " + com.aspose.cells.a.c.zl.a(var26));
                                    }
                                 }
                              } else {
                                 var34.b(var36);
                              }
                           }
                        }
                     }

                     ++var35;
                  }
               } else {
                  Iterator var13 = this.k.iterator();

                  label396:
                  while(true) {
                     Worksheet var14;
                     do {
                        if (!var13.hasNext()) {
                           this.a = true;
                           var24 = false;
                           break label396;
                        }

                        var14 = (Worksheet)var13.next();
                        var34 = var14.getCells().b;
                     } while(var34.c < 1);

                     var33 = var14.getCells().getRows().a;

                     for(int var15 = 0; var15 < var34.b.length; ++var15) {
                        var12 = var34.a(var15);
                        if (var12 != null && var12.c() != 2) {
                           var11 = var33.a(var12.e, var12.f);
                           if (var11 != null && var11.c.d == var12) {
                              try {
                                 zabd var16 = this.k.x().a(var11);
                                 if (var16 != null) {
                                    Object var17 = var32.a(var16, var11);
                                    if (var11.isArrayHeader()) {
                                       zyd.a(var17, var11);
                                    } else {
                                       var11.a((Object)var17, (byte)2);
                                    }
                                 }
                              } catch (Exception var27) {
                                 if (!ignoreError) {
                                    throw new CellsException(5, "Error in calculating cell [" + var11.d.h().getName() + "!" + var11.i() + "]: " + com.aspose.cells.a.c.zl.a(var27));
                                 }
                              }
                           } else {
                              var34.b(var15);
                           }
                        }
                     }
                  }
               }
            } finally {
               if (var24) {
                  for(int var19 = 0; var19 < var6; ++var19) {
                     this.k.get(var19).getCells().getRows().a();
                  }

               }
            }

            for(var7 = 0; var7 < var6; ++var7) {
               this.k.get(var7).getCells().getRows().a();
            }

         }
      }
   }

   public void calculateFormula(CalculationOptions options) {
      boolean var2 = !this.getSettings().getParsingFormulaOnOpen() && !this.getSettings().m && this.i() == 1;
      boolean var3 = true;
      boolean var4 = false;
      int var5 = this.k.getCount();

      int var6;
      for(var6 = 0; var6 < var5; ++var6) {
         zaau var7 = this.k.get(var6).getCells().b;
         if (this.j.getCreateCalcChain() && var7.e == null) {
            var7.e = new zyq(var7);
         }

         if (var7.c > 0) {
            zyi[] var8 = var7.b;
            if (var3) {
               var3 = false;
            }

            int var9;
            if (var2) {
               for(var9 = var8.length - 1; var9 > -1; --var9) {
                  if (var8[var9] != null && var8[var9].j()) {
                     var2 = false;
                     var4 = true;
                     break;
                  }
               }
            }

            if (!this.a) {
               for(var9 = 0; var9 < var8.length; ++var9) {
                  if (var8[var9] != null) {
                     var8[var9].a((byte)0);
                  }
               }
            }
         }
      }

      if (!var3) {
         this.k.ae();
         boolean var19 = false;

         try {
            var19 = true;

            for(int var22 = 0; var22 < var5; ++var22) {
               Cells var21 = this.k.get(var22).getCells();
               var21.getRows().a(16);
            }

            if (var4) {
               this.d();
            }

            zaay var10 = new zaay(this, 1, options);
            zfv var11 = new zfv();
            Iterator var13 = this.k.iterator();

            label274:
            while(true) {
               Worksheet var14;
               zaau var24;
               do {
                  if (!var13.hasNext()) {
                     if (this.j.getCreateCalcChain()) {
                        this.a = true;
                        var10.p.f();
                        var19 = false;
                     } else {
                        var19 = false;
                     }
                     break label274;
                  }

                  var14 = (Worksheet)var13.next();
                  var24 = var14.getCells().b;
               } while(var24.c < 1);

               zafu var23 = var14.getCells().getRows().a;
               var10.a(var14);

               for(int var15 = 0; var15 < var24.b.length; ++var15) {
                  zyi var25 = var24.a(var15);
                  if (var25 != null && var25.c() != 2) {
                     var11.a = var25.f;
                     zfv var12 = var23.a(var25.e, var11, 4);
                     if (var12 != null && var12.d == var25) {
                        var10.b(var25);
                     } else {
                        var24.b(var15);
                     }
                  }
               }

               var10.p.a(var14.getIndex());
            }
         } finally {
            if (var19) {
               for(int var17 = 0; var17 < var5; ++var17) {
                  this.k.get(var17).getCells().getRows().a();
               }

            }
         }

         for(var6 = 0; var6 < var5; ++var6) {
            this.k.get(var6).getCells().getRows().a();
         }

      }
   }

   public Style getDefaultStyle() {
      return this.k.D();
   }

   public void setDefaultStyle(Style value) {
      this.k.b(value);
   }

   /** @deprecated */
   public boolean validateFormula(String formula) {
      if (formula != null && formula.length() >= 2 && formula.charAt(0) == '=') {
         formula = formula.substring(1);
         zabg var2 = new zabg(this.k);
         var2.a = true;

         try {
            var2.a(formula.toUpperCase());
            var2.a();
            return var2.a;
         } catch (Exception var4) {
            return false;
         }
      } else {
         return false;
      }
   }

   public Color getMatchingColor(Color rawColor) {
      Color var2 = rawColor;
      int var3 = Integer.MAX_VALUE;
      boolean var4 = false;
      Color[] var5 = this.j.c().c();
      int var6 = var5.length;

      for(int var7 = 0; var7 < var6; ++var7) {
         Color var8 = var5[var7];
         int var9 = com.aspose.cells.b.a.ze.f(Math.pow((double)((com.aspose.cells.a.c.zh.b(var8) & 255) - (com.aspose.cells.a.c.zh.b(rawColor) & 255)), 2.0D) + Math.pow((double)((com.aspose.cells.a.c.zh.c(var8) & 255) - (com.aspose.cells.a.c.zh.c(rawColor) & 255)), 2.0D) + Math.pow((double)((com.aspose.cells.a.c.zh.d(var8) & 255) - (com.aspose.cells.a.c.zh.d(rawColor) & 255)), 2.0D));
         if (var9 < var3) {
            var2 = var8;
            if (var9 == 0) {
               break;
            }

            var3 = var9;
         }
      }

      return var2;
   }

   public void protect(int protectionType, String password) {
      this.k.a(protectionType, password);
   }

   public void unprotect(String password) {
      this.k.f(password);
   }

   /** @deprecated */
   public void decrypt(String password) {
      this.getSettings().setPassword((String)null);
   }

   public void removeMacro() {
      this.k.l = null;
      this.k.b(false);
   }

   public VbaProject getVbaProject() throws Exception {
      VbaProject var1 = this.getWorksheets().ag();
      if (var1 == null) {
         this.getWorksheets().l = new VbaProject(this);
         var1 = this.getWorksheets().l;
         this.getWorksheets().b(true);
      }

      return var1;
   }

   public void removeDigitallySign() {
      if (this.b != null) {
         this.b.b();
      }

      if (this.getWorksheets().f() != null) {
         this.getWorksheets().f().a().g("_signatures");
      }

      this.i = null;
      this.t = null;
   }

   public void acceptAllRevisions() {
      zbah var1 = new zbah(this);
      var1.b();
   }

   public boolean hasMacro() {
      if (this.k.f() == null || this.k.i() && !this.k.j()) {
         return this.k.l != null;
      } else {
         return false;
      }
   }

   public boolean isDigitallySigned() {
      if (this.b != null) {
         return this.b.m;
      } else {
         return this.getWorksheets().f() != null ? this.getWorksheets().f().a().b("_signatures") : false;
      }
   }

   public boolean hasRevisions() throws Exception {
      zbah var1 = new zbah(this);
      return var1.a();
   }

   public String getFileName() {
      return this.l;
   }

   public void setFileName(String value) {
      this.b(value);
   }

   private void b(String var1) {
      this.l = var1;
   }

   public DataSorter getDataSorter() {
      if (this.m == null) {
         this.m = new DataSorter(this);
      }

      return this.m;
   }

   public void removeExternalLinks() {
      this.d();
      boolean var1 = false;
      int var2 = this.getWorksheets().v().getCount();
      boolean[] var3 = new boolean[var2];

      for(int var4 = 0; var4 < var2; ++var4) {
         zbqg var5 = this.getWorksheets().v().a(var4);
         switch(var5.a()) {
         case 0:
            if (!var5.g()) {
               var3[var4] = true;
               var1 |= var3[var4];
               var5.b((ArrayList)null);
            }
            break;
         case 3:
            var3[var4] = true;
            var1 |= var3[var4];
            var5.b((ArrayList)null);
         }
      }

      if (var1) {
         HashMap var8 = new HashMap();

         int var6;
         for(int var9 = 0; var9 < this.getWorksheets().q().getCount(); ++var9) {
            var6 = this.getWorksheets().q().b(var9).a;
            if (var3[var6 & '\uffff']) {
               var8.put(var9, var9);
            }
         }

         if (var8.size() != 0) {
            HashMap var10 = new HashMap();

            for(var6 = 0; var6 < this.getWorksheets().getNames().getCount(); ++var6) {
               Name var7 = this.getWorksheets().getNames().get(var6);
               if (var7.b() != null && zyo.a(var7.b(), -1, -1, (WorksheetCollection)this.getWorksheets())) {
                  var7.u();
                  var7.a(true);
                  var10.put(var6, true);
               }
            }

            for(var6 = 0; var6 < this.getWorksheets().getCount(); ++var6) {
               this.getWorksheets().get(var6).getCells().getRows().a(var8, var10);
               this.getWorksheets().get(var6).getCharts().b();
            }

         }
      }
   }

   void a(com.aspose.cells.b.a.d.zm var1) throws Exception {
      this.b = new zps(this);
      this.b.b = new zpn();
      this.b.b.a(var1);
      com.aspose.cells.a.c.zl.c("Finished loading zip data.");
   }

   int e() {
      return this.n;
   }

   void a(int var1) {
      this.n = var1;
   }

   int f() {
      return this.o;
   }

   void b(int var1) {
      this.o = var1;
   }

   public void setEncryptionOptions(int encryptionType, int keyLength) {
      this.n = encryptionType;
      this.o = keyLength;
   }

   public boolean checkWriteProtectedPassword(String password) {
      WorkbookSettings var2 = this.getSettings();
      if (!var2.j) {
         return true;
      } else if (password != null && !"".equals(password)) {
         int var3 = zsw.a(password);
         return var3 == var2.k;
      } else {
         return (var2.k & '\uffff') == 0;
      }
   }

   SaveOptions g() {
      return this.p;
   }

   /** @deprecated */
   public SaveOptions getSaveOptions() {
      if (this.p == null) {
         this.p = new SaveOptions();
      }

      return this.p;
   }

   void a(SaveOptions var1) {
      this.p = var1;
   }

   public Color getThemeColor(int type) {
      return this.c.a(type);
   }

   public void setThemeColor(int type, Color color) {
      this.c.e[type].a(color);
      this.d = true;
   }

   public String getTheme() {
      return this.c.a;
   }

   public void customTheme(String themeName, Color[] colors) {
      this.c = new zqm(themeName, colors);
      this.d = true;
   }

   public void copyTheme(Workbook source) {
      this.c.a(source.c);
      this.d = true;
   }

   String h() {
      if (this.l != null && !"".equals(this.l)) {
         String var1 = com.aspose.cells.a.c.zt.b(this.l);
         return var1.length() == this.l.length() ? null : this.l.substring(0, 0 + (this.l.length() - var1.length()));
      } else {
         return null;
      }
   }

   public boolean hasExernalLinks() {
      int var1 = 0;

      while(var1 < this.getWorksheets().v().getCount()) {
         zbqg var2 = this.getWorksheets().v().a(var1);
         switch(var2.a()) {
         case 0:
            return true;
         default:
            ++var1;
         }
      }

      return false;
   }

   public void updateLinkedDataSource(Workbook[] exteralWorkbooks) throws Exception {
      if (this.hasExernalLinks()) {
         this.b();

         for(int var2 = 0; var2 < this.getWorksheets().v().getCount(); ++var2) {
            zbqg var3 = this.getWorksheets().v().a(var2);
            switch(var3.a()) {
            case 0:
               String var4 = var3.a(this);
               if (com.aspose.cells.b.a.d.zd.c(var4)) {
                  Workbook var5 = null;
                  if (exteralWorkbooks != null) {
                     for(int var6 = 0; var6 < exteralWorkbooks.length; ++var6) {
                        Workbook var7 = exteralWorkbooks[var6];
                        if (com.aspose.cells.b.a.zv.b(var7.getFileName().toUpperCase(), var4.toUpperCase())) {
                           var5 = var7;
                           break;
                        }
                     }
                  }

                  if (var5 == null) {
                     LoadOptions var16 = new LoadOptions();
                     var16.setLoadDataAndFormatting(true);
                     var16.getLoadDataOptions().setImportFormula(false);
                     var5 = new Workbook(var4, var16);
                  }

                  ArrayList var17 = var3.d();
                  if (var17 != null) {
                     var17.clear();
                  }

                  int var19;
                  zuk var21;
                  String var23;
                  Name var25;
                  if (var3.c() == null) {
                     var3.a(new String[var5.getWorksheets().getCount()]);

                     for(var19 = 0; var19 < var5.getWorksheets().getCount(); ++var19) {
                        var3.c()[var19] = var5.getWorksheets().get(var19).getName();
                     }

                     for(var19 = 0; var19 < var3.b().size(); ++var19) {
                        var21 = (zuk)var3.b().get(var19);
                        var23 = var21.e();
                        if (var21.d() != 0) {
                           var23 = var5.getWorksheets().get(var21.d() - 1).getName() + "!" + var23;
                        }

                        var25 = var5.getWorksheets().getNames().get(var23);
                        if (var25 != null && var25.getRefersTo() != null) {
                           var21.a(this.getWorksheets(), var25.getRefersTo());
                        }

                        if (var21.f() != null) {
                           zyo.a(var21.f(), -1, -1, var5.getWorksheets(), var5.getWorksheets(), 0, var3, true, this);
                        }
                     }
                  } else {
                     String[] var18 = var3.c();
                     var3.a(new String[var5.getWorksheets().getCount()]);

                     for(int var8 = 0; var8 < var5.getWorksheets().getCount(); ++var8) {
                        var3.c()[var8] = var5.getWorksheets().get(var8).getName();
                     }

                     HashMap var20 = new HashMap();

                     int var11;
                     for(int var9 = 0; var9 < var18.length; ++var9) {
                        String var10 = var18[var9].toUpperCase();

                        for(var11 = 0; var11 < var5.getWorksheets().getCount(); ++var11) {
                           if (com.aspose.cells.b.a.zv.b(var5.getWorksheets().get(var11).getName().toUpperCase(), var10)) {
                              var20.put(var9, var11);
                              break;
                           }
                        }
                     }

                     this.getWorksheets().q().a(var2, var20);

                     for(var19 = 0; var19 < var3.b().size(); ++var19) {
                        var21 = (zuk)var3.b().get(var19);
                        var23 = var21.e();
                        if (var21.d() != 0) {
                           var23 = var5.getWorksheets().get(var21.d() - 1).getName() + "!" + var23;
                        }

                        var25 = var5.getWorksheets().getNames().get(var23);
                        if (var25 != null && var25.getRefersTo() != null) {
                           var21.a(this.getWorksheets(), var25.getRefersTo());
                        }

                        if (var21.f() != null) {
                           zyo.a(var21.f(), -1, -1, var5.getWorksheets(), var5.getWorksheets(), 0, var3, true, this);
                        }
                     }

                     for(var19 = 0; var19 < this.k.getCount(); ++var19) {
                        Cells var22 = this.k.get(var19).getCells();
                        var23 = null;

                        for(int var26 = 0; var26 < var22.getRows().getCount(); ++var26) {
                           Row var29 = var22.getRows().c(var26);

                           for(int var12 = 0; var12 < var29.a(); ++var12) {
                              Cell var27 = var29.getCellByIndex(var12);
                              if (var27.f()) {
                                 zyi var13 = var27.g();
                                 zyo.a(var13.b, -1, -1, this.k, var5.getWorksheets(), var2, var3, false, this);
                                 if (var13.a() != null) {
                                    zyo.a(var13.a().d(), -1, -1, this.k, var5.getWorksheets(), var2, var3, false, this);
                                 }
                              }
                           }
                        }

                        ChartCollection var28 = this.k.get(var19).getCharts();

                        for(var11 = 0; var11 < var28.getCount(); ++var11) {
                           Chart var30 = var28.get(var11);

                           for(int var31 = 0; var31 < var30.getNSeries().getCount(); ++var31) {
                              zik var14 = var30.getNSeries().get(var31).l();
                              if (var14 != null) {
                                 byte[] var15 = var14.f();
                                 if (var15 != null && zyo.a(var15, -1, -1, (WorksheetCollection)this.k)) {
                                    zyo.a(var15, -1, -1, this.k, var5.getWorksheets(), var2, var3, false, this);
                                 }
                              }
                           }
                        }
                     }

                     for(var19 = 0; var19 < this.k.getNames().getCount(); ++var19) {
                        Name var24 = this.k.getNames().get(var19);
                        if (var24.b() != null) {
                           zyo.a(var24.b(), -1, -1, this.k, var5.getWorksheets(), var2, var3, false, this);
                        }
                     }
                  }
               }
            case 3:
            }
         }

      }
   }

   public BuiltInDocumentPropertyCollection getBuiltInDocumentProperties() {
      return this.getWorksheets().getBuiltInDocumentProperties();
   }

   public CustomDocumentPropertyCollection getCustomDocumentProperties() {
      return this.getWorksheets().getCustomDocumentProperties();
   }

   public int getFileFormat() {
      return this.e;
   }

   public void setFileFormat(int value) {
      this.e = value;
      int var2 = a(value, this.q, true);
      if (var2 != this.q) {
         this.a(this.q, var2);
      }

      this.q = var2;
   }

   void a(int var1, boolean var2) {
      this.e = var1;
      int var3 = a(var1, this.q, var2);
      if (var3 != this.q) {
         this.a(this.q, var3);
      }

      this.q = var3;
   }

   void c(int var1) {
      this.e = var1;
      int var2 = a(var1, this.q, true);
      this.q = var2;
   }

   int i() {
      return this.q;
   }

   private void d(int var1) {
      this.e = var1;
      this.q = a(var1, this.q, true);
   }

   private static int a(int var0, int var1, boolean var2) {
      switch(var0) {
      case 5:
         return 0;
      case 6:
      case 7:
      case 8:
      case 9:
      case 10:
      case 16:
         return 1;
      case 11:
      case 12:
      case 13:
      case 14:
      default:
         return var1;
      case 15:
         return var2 ? 0 : var1;
      }
   }

   boolean j() {
      return this.q == 1;
   }

   boolean k() {
      return this.q == 1;
   }

   private void a(int var1, int var2) {
      switch(var1) {
      case 0:
         switch(var2) {
         case 0:
         default:
            return;
         case 1:
            this.o();
            return;
         }
      case 1:
         switch(var2) {
         case 0:
            this.p();
         case 1:
         }
      }

   }

   private void o() {
      int var2 = 0;
      int var3 = 0;
      NameCollection var4 = this.k.getNames();

      byte[] var1;
      int var5;
      for(var5 = 0; var5 < var4.getCount(); ++var5) {
         Name var6 = var4.get(var5);
         var1 = var6.b();
         if (var1 != null && var1.length > 2) {
            var6.a(zcq.a(var1, -1, 0, 0, true));
         }
      }

      Iterator var16 = this.k.v().iterator();

      while(true) {
         zbqg var17;
         do {
            do {
               if (!var16.hasNext()) {
                  for(var5 = 0; var5 < this.k.getCount(); ++var5) {
                     Worksheet var18 = this.k.get(var5);
                     if (var18.getType() == 2 && var18.getCharts().getCount() > 0) {
                        Chart var20 = var18.getCharts().get(0);
                        var20.F();
                     } else {
                        if (var18.t() != null && var18.t().getCount() > 0) {
                           var18.getShapes().m();
                        }

                        Cells var19 = var18.getCells();
                        zr var21 = var19.f();
                        if (var21.a() > 0) {
                           zahl var10 = var21.b();

                           label98:
                           while(true) {
                              zp var9;
                              int var12;
                              do {
                                 var12 = var10.a();
                                 if (var12 < 0) {
                                    break label98;
                                 }

                                 var9 = var21.f(var12);
                              } while(var9.a() <= 0);

                              int var13 = var9.h();
                              zahl var11 = var9.b();

                              while(true) {
                                 var12 = var11.a();
                                 if (var12 < 0) {
                                    break;
                                 }

                                 if (var9.h(var12) == 5) {
                                    zyi var15 = (zyi)var9.i(var12);
                                    var1 = var15.b;
                                    if (var1 != null) {
                                       int var14 = var9.a(var12);
                                       var15.b = zcq.a(var1, -1, var13, var14, false);
                                       if (var15.a() != null) {
                                          var1 = var15.a().d();
                                          var15.a().a(zcq.a(var1, -1, var13, var14, false));
                                       }
                                    }
                                 }
                              }
                           }
                        }

                        ValidationCollection var22 = var18.getValidations();

                        for(int var23 = 0; var23 < var22.getCount(); ++var23) {
                           Validation var25 = var22.get(var23);
                           int[] var28 = new int[]{var2};
                           int[] var30 = new int[]{var3};
                           var25.a(var28, var30);
                           var2 = var28[0];
                           var3 = var30[0];
                           if (var25.d() != null) {
                              var25.a(zcq.a(var25.d(), 0, var2, var3, true));
                           }

                           if (var25.e() != null) {
                              var25.b(zcq.a(var25.e(), 0, var2, var3, true));
                           }
                        }

                        ConditionalFormattingCollection var24 = var18.m;
                        if (var24 != null && var24.getCount() > 0) {
                           for(int var26 = 0; var26 < var24.getCount(); ++var26) {
                              FormatConditionCollection var29 = var24.get(var26);
                              var29.c(true);
                           }
                        }

                        SparklineGroupCollection var27 = var18.getSparklineGroupCollection();
                        if (var27.getCount() > 0) {
                           var27.c();
                        }
                     }
                  }

                  return;
               }

               var17 = (zbqg)var16.next();
            } while(var17.b() == null);
         } while(var17.b().size() <= 0);

         for(int var7 = 0; var7 < var17.b().size(); ++var7) {
            zuk var8 = (zuk)var17.b().get(var7);
            zcq.a(var8);
         }
      }
   }

   private void p() {
      this.d();
      int var2 = 0;
      int var3 = 0;
      NameCollection var4 = this.k.getNames();

      byte[] var1;
      int var5;
      for(var5 = 0; var5 < var4.getCount(); ++var5) {
         Name var6 = var4.get(var5);
         var1 = var6.b();
         if (var1 != null && var1.length > 2) {
            var6.a(zcr.a(var1, -1));
         }
      }

      Iterator var16 = this.k.v().iterator();

      while(true) {
         zbqg var17;
         do {
            do {
               if (!var16.hasNext()) {
                  for(var5 = 0; var5 < this.k.getCount(); ++var5) {
                     Worksheet var18 = this.k.get(var5);
                     if (var18.getType() == 2) {
                        Chart var20 = var18.getCharts().get(0);
                        var20.G();
                     } else {
                        if (var18.t() != null && var18.t().getCount() > 0) {
                           var18.t().l();
                        }

                        Cells var19 = var18.getCells();
                        zr var21 = var19.f();
                        if (var21.a() > 0) {
                           zahl var9 = var21.b();
                           RowCollection var12 = var19.getRows();

                           label95:
                           while(true) {
                              zp var11;
                              Row var13;
                              int var15;
                              do {
                                 var15 = var9.a();
                                 if (var15 < 0) {
                                    break label95;
                                 }

                                 var11 = var21.f(var15);
                                 var13 = new Row(var19, var12, var11, false);
                              } while(var11.a() <= 0);

                              zahl var10 = var11.b();

                              while(true) {
                                 var15 = var10.a();
                                 if (var15 < 0) {
                                    break;
                                 }

                                 if (var11.h(var15) == 5) {
                                    Cell var14 = new Cell(var13, var15);
                                    var1 = var14.v();
                                    if (var1 != null) {
                                       var14.a(zcr.a(var1, -1));
                                       if (var14.g().a() != null) {
                                          var1 = var14.g().a().d();
                                          var14.g().a().a(zcr.a(var1, -1));
                                       }
                                    }
                                 }
                              }
                           }
                        }

                        ValidationCollection var22 = var18.getValidations();

                        for(int var23 = 0; var23 < var22.getCount(); ++var23) {
                           Validation var25 = var22.get(var23);
                           int[] var27 = new int[]{var2};
                           int[] var30 = new int[]{var3};
                           var25.a(var27, var30);
                           var2 = var27[0];
                           var3 = var30[0];
                           if (var25.d() != null) {
                              var25.a(zcr.a(var25.d(), 0));
                           }

                           if (var25.e() != null) {
                              var25.b(zcr.a(var25.e(), 0));
                           }
                        }

                        ConditionalFormattingCollection var24 = var18.m;
                        if (var24 != null && var24.getCount() > 0) {
                           for(int var26 = 0; var26 < var24.getCount(); ++var26) {
                              FormatConditionCollection var29 = var24.get(var26);
                              var29.c(false);
                           }
                        }

                        SparklineGroupCollection var28 = var18.getSparklineGroupCollection();
                        if (var28.getCount() > 0) {
                           var28.d();
                        }
                     }
                  }

                  return;
               }

               var17 = (zbqg)var16.next();
            } while(var17.b() == null);
         } while(var17.b().size() <= 0);

         for(int var7 = 0; var7 < var17.b().size(); ++var7) {
            zuk var8 = (zuk)var17.b().get(var7);
            zcr.a(var8);
         }
      }
   }

   private com.aspose.cells.b.a.d.zm a(zvh var1, byte[] var2) throws Exception {
      byte var3 = 8;
      int var4 = com.aspose.cells.b.a.zc.a(var2, var3);
      long var5 = com.aspose.cells.b.a.zc.d(var2, var3 + 12);
      long var7 = com.aspose.cells.b.a.zc.d(var2, var3 + 16);
      com.aspose.cells.b.a.zc.d(var2, var3 + 20);
      long var11 = com.aspose.cells.b.a.zc.d(var2, var3 + 24);
      int var19 = 12 + var4;
      var4 = com.aspose.cells.b.a.zc.a(var2, var19);
      var19 += 4;
      byte[] var13 = new byte[var4];
      byte[] var14 = new byte[var4];
      System.arraycopy(var2, var19, var13, 0, var4);
      var19 += var4;
      System.arraycopy(var2, var19, var14, 0, var4);
      var19 += var4;
      var19 += 4;
      byte[] var15 = new byte[var2.length - var19];
      System.arraycopy(var2, var19, var15, 0, var15.length);
      int var10000 = var19 + var4;

      try {
         zbv var16 = null;
         String var17 = this.getSettings().getPassword();
         if (var17 == null || "".equals(var17)) {
            var17 = "VelvetSweatshop";
         }

         var16 = new zbv(var17, var13, var14, var15, "", var11, 0L, var7, var5);
         if (var16.a()) {
            return var16.a(var1.a().a("EncryptedPackage"));
         } else {
            throw new CellsException(8, "Invalid password.");
         }
      } catch (Exception var18) {
         if (this.getSettings().getPassword() != null && !"".equals(this.getSettings().getPassword())) {
            throw new CellsException(8, "Invalid password.");
         } else {
            throw new CellsException(8, "Please provide password for the Workbook file.");
         }
      }
   }

   private com.aspose.cells.b.a.d.zm b(zvh var1) throws Exception {
      com.aspose.cells.b.a.d.zh var2 = var1.a().a("EncryptionInfo");
      byte[] var3 = new byte[(int)var2.h()];
      var2.a(var3, 0, var3.length);
      String var4;
      if (var3[0] == 1 && var3[2] == 1) {
         var4 = "VelvetSweatshop";
         if (this.getSettings().getPassword() != null && !"".equals(this.getSettings().getPassword())) {
            var4 = this.getSettings().getPassword();
         }

         byte[] var15 = new byte[16];
         System.arraycopy(var3, 4, var15, 0, 16);
         byte[] var6 = new byte[16];
         System.arraycopy(var3, 20, var6, 0, 16);
         byte[] var7 = new byte[16];
         System.arraycopy(var3, 36, var7, 0, 16);
         zsg var8 = new zsg(var4, var15, var6, var7, 512);
         com.aspose.cells.b.a.d.zh var9 = var1.a().a("EncryptedPackage");
         byte[] var10 = new byte[16];
         var9.b(8L);
         com.aspose.cells.b.a.d.zh var11 = new com.aspose.cells.b.a.d.zh();

         for(int var12 = 0; (long)var12 < (var9.h() - 8L + 15L) / 16L; ++var12) {
            int var13 = var9.a(var10, 0, var10.length);
            byte[] var14 = var8.a(var10, 0, 16, ((long)var12 & 4294967295L) * 16L);
            var11.b(var14, 0, var13);
         }

         var11.b(0L);
         return var11;
      } else if (var3[0] == 4 && var3[2] == 4) {
         var4 = "VelvetSweatshop";
         if (this.getSettings().getPassword() != null && !"".equals(this.getSettings().getPassword())) {
            var4 = this.getSettings().getPassword();
         }

         zsv var5 = new zsv(var1, var3, Encoding.getUnicode().a(var4));
         if (var5.a()) {
            return var5.b();
         } else {
            throw new CellsException(8, "Invalid password.");
         }
      } else {
         return this.a(var1, var3);
      }
   }

   void l() {
      if (this.r != null && this.r.a) {
         throw new CellsException(17, "Interrupted by user");
      }
   }

   public InterruptMonitor getInterruptMonitor() {
      return this.r;
   }

   public void setInterruptMonitor(InterruptMonitor value) {
      this.r = value;
   }

   public ContentTypePropertyCollection getContentTypeProperties() throws Exception {
      if (this.f == null) {
         this.f = new ContentTypePropertyCollection();
         zaiv var1 = new zaiv(this);
         if (this.g == null && this.getWorksheets().f() != null) {
            var1.a(this.getWorksheets().f());
         }

         var1.a();
      }

      return this.f;
   }

   zng m() {
      if (this.g == null) {
         this.g = new zng();
      }

      return this.g;
   }

   public String getRibbonXml() {
      return this.s;
   }

   public void setRibbonXml(String value) {
      this.s = value;
   }

   public ExternalConnectionCollection getDataConnections() {
      return this.h == null ? (this.h = new ExternalConnectionCollection(this)) : this.h;
   }

   public void importXml(String url, String sheetName, int row, int col) throws Exception {
      XmlMap var5 = new XmlMap();
      var5.c = this.getWorksheets().getXmlMaps().getCount() + 1;
      com.aspose.cells.b.a.a.ze.a(this.getWorksheets().getXmlMaps().b, (Object)zase.aM(this.getWorksheets().getXmlMaps().getCount() + 1));
      this.getWorksheets().getXmlMaps().c = "";
      var5.h = "Schema" + (this.getWorksheets().getXmlMaps().getCount() + 1);
      var5.j = new zcfj();
      var5.j.c = true;
      this.getWorksheets().getXmlMaps().a(var5);
      Worksheet var6 = this.getWorksheets().get(sheetName);
      int var7 = var6.getListObjects().c();
      ListObject var8 = var6.getListObjects().get(var7);
      zcfo.a(var5, url, var6, var8, row, col);
   }

   public void setDigitalSignature(DigitalSignatureCollection digitalSignatureCollection) {
      this.t = digitalSignatureCollection;
   }

   public DigitalSignatureCollection getDigitalSignature() {
      return this.i == null ? null : this.i.a();
   }

   void b(com.aspose.cells.b.a.d.zm var1) throws Exception {
      if (this.t != null && this.t.a.size() > 0) {
         var1.b(0L);
         zarw var2 = new zarw(this.t);
         var2.a(var1);
      }

   }

   void a(zok var1) {
      if (this.t != null && this.t.a.size() > 0) {
         if (this.isDigitallySigned()) {
            if (this.b != null) {
               this.b.b();
            }

            if (this.getWorksheets().f() != null) {
               this.getWorksheets().f().a().g("_signatures");
            }

            this.i = null;
         }

         var1.w = true;
      }

   }

   HashMap n() {
      return this.u;
   }

   public void dispose() {
      this.k = null;
      this.p = null;
      this.r = null;
      this.h = null;
      this.f = null;
      this.g = null;
      this.s = null;
      this.b = null;
      this.u = null;
      this.t = null;
   }
}
